package org.wannatrak.android.activity;

import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
import org.wannatrak.android.R;
import org.wannatrak.android.helper.UIHelper;
import org.wannatrak.android.intf.DialogAction;
import org.wannatrak.android.maps.PointsOverlay;

import java.util.List;

/**
 * @Author: Maksim Tulupov maxtulupov@gmail.com
 * @Date: $Date: 2011-06-20 05:08:37 +0000 (Mon, 20 Jun 2011) $ 2:35 PM
 * @version: $Revision: 13 $
 * @id: $Id: MapViewSpinnerHandler.java 13 2011-06-20 05:08:37Z maxtulupov@gmail.com $
 */
public class MapViewSpinnerHandler extends Handler {

    private MapActivity mapActivity;

    public MapViewSpinnerHandler(MapActivity mapActivity) {
        this.mapActivity = mapActivity;
    }

    @Override
    public void handleMessage(Message msg) {
        if (msg.what >= 0) {
            Spinner spinner = (Spinner) mapActivity.findViewById(R.id.tracksSpinner);
            spinner.setAdapter((SpinnerAdapter) msg.obj);
            if (msg.arg1 >= 0) {
                spinner.setSelection(msg.arg1);
            }
        } else {
            UIHelper.createAlertDialog(mapActivity, (String) msg.obj, -1, true, (DialogAction[]) null).show();
        }
    }
}
